<div class="section" id="sitemaplist">

	<div class="section-title"><?php echo $this->document->title?></div>
    
    <div class="section-content padding1">
    
    	<form  id="frm_receipt" action="<?php echo $action?>" method="post" enctype="multipart/form-data">
        	
            
        	<div class="button right">
            	<input type="button" value="Lưu" class="button" onClick="save('')"/>
                <input type="button" value="Bỏ qua" class="button" onclick="linkto('?route=quanlykho/phieuxuat')"/>  
     	        <input type="hidden" name="id" value="<?php echo $item['id']?>">
                <input type="hidden" name="code" value="<?php echo $item['code']?>">
                <input type="hidden" id="receiptdate" name="receiptdate" value="<?php echo $item['receiptdate']?>">
                <input type="hidden" id="status" name="status" value="<?php echo $item['status']?>">
            </div>
            <div class="clearer">^&nbsp;</div>
        	<div id="error" class="error" style="display:none"></div>
        	<div id="container">
            	<ul>
                    <li class="tabs-selected"><a href="#fragment-customerinfo" ><span>Thông tin khách hàng</span></a></li>
                    <li><a href="#fragment-carinfo"><span>Thông tin xe</span></a></li>
                    
                    
                    
                </ul>
                <div id="fragment-customerinfo">
                	<p>
                        <label>Tên</label><br />
                        <input type="text" id="customername" name="customername" value="<?php echo $item['customername']?>" class="text" size=60/>
                        <input type="hidden" id="customerid" name="customerid" value="<?php echo $item['customerid']?>"/>
                        <input type="button" class="button" id="btnSelectKhachHang" value="Chọn khách hàng" />
                    </p>
                    <p>
                        <label>Số điện thoại</label><br />
                        <input type="text" id="phone" name="phone" value="<?php echo $item['phone']?>" class="text" size=60/>
                        
                    </p>
                    <p>
                        <label>Email</label><br />
                        <input type="text" id="email" name="email" value="<?php echo $item['email']?>" class="text" size=60/>
                        
                    </p>
                    <p>
                        <label>Địa chỉ</label><br />
                        <input type="text" id="address" name="address" value="<?php echo $item['address']?>" class="text" size=60/>
                        
                    </p>
                    

                </div>
                <div id="fragment-carinfo">
                	<p>
                        <label>Số xe</label><br />
                        <input type="text" id="carnumber" name="carnumber" value="<?php echo $item['carnumber']?>" class="text" size=60/>
                        <input type="hidden" id="carid" name="carid" value="<?php echo $item['carid']?>"/>
                        <input type="button" class="button" id="btnSelectCar" value="Chọn xe" />
                    </p>
                    <p>
                        <label>Hảng xe</label><br />
                        
                        <select id="manufacturer" name="manufacturer">
                        	<option value=""></option>
                        	<?php foreach($manufacturer as $it){ ?>
                        
                        	<option value="<?php echo $it['categoryid']?>"><?php echo $this->string->getPrefix("&nbsp;&nbsp;&nbsp;&nbsp;",$it['level']-1) ?><?php echo $it['categoryname']?></option>
                        	
                        
                        	<?php } ?>
                        </select>
                        
                    </p>
                    <p>
                        <label>Dòng xe</label><br />
                        <input type="text" id="model" name="model" value="<?php echo $item['model']?>" class="text" size=60/>
                        
                    </p>
                    <p>
                        <label>Màu</label><br />
                        <input type="text" id="color" name="color" value="<?php echo $item['color']?>" class="text" size=60/>
                        
                    </p>
                    <p>
                    	<label>Mô tả</label><br />
                        <textarea id="description" name="description"><?php echo $item['description']?></textarea>
                    </p>
                </div>
                
            </div>
            
        </form>
    
    </div>
    
</div>
<script type="text/javascript" charset="utf-8">
function save()
{
	if($('#receiptdate').val()=="" || $('#receiptdate').val()=="0000-00-00 00:00:00")
		$('#receiptdate').val(toPhpTime(Date.now()));
	if($('#status').val()=="")
		$('#status').val('new');
	$.post("?route=gara/receipt/save",$('#frm_receipt').serialize(),
		function(data){
			if(data=="true")
			{
				window.location = "?route=gara/receipt";
				
			}
			else
			{
				$('#error').html(data).show('slow');
				$.unblockUI();
			}
			
		});
}


$('#btnSelectKhachHang').click(function(e) {
	$('body').append('<div id="customerform" style="display:none"></div>');
	var eid = "#customerform";
    $(eid).attr('title','Chọn khách hàng');
		$( eid ).dialog({
			autoOpen: false,
			show: "blind",
			hide: "explode",
			width: 900,
			height: 600,
			modal: true,
		});
	
		
		$(eid).load("?route=core/member&opendialog=true",function(){
			$(eid).dialog("open");
		});
});
function intSelectMember()
{
	$('.item').click(function(e) {
		
        $('#customerid').val($(this).attr('id'));
		$('#customername').val($(this).attr('fullname'));
		$('#email').val($(this).attr('email'));
		$('#phone').val($(this).attr('phone'));
		$('#address').val($(this).attr('address'));
		
		$("#customerform").dialog( "close" );
    });
}
$('#btnSelectCar').click(function(e) {
	$('body').append('<div id="carform" style="display:none"></div>');
	var eid = "#carform";
    $(eid).attr('title','Chọn xe');
		$( eid ).dialog({
			autoOpen: false,
			show: "blind",
			hide: "explode",
			width: 900,
			height: 600,
			modal: true,
		});
	
		
		$(eid).load("?route=gara/car&opendialog=true",function(){
			$(eid).dialog("open");
		});
});
function intSelectCar()
{
	$('.item').click(function(e) {
		
        $('#carid').val($(this).attr('id'));
		$('#carnumber').val($(this).attr('carnumber'));
		$('#manufacturer').val($(this).attr('manufacturer'));
		$('#model').val($(this).attr('model'));
		$('#color').val($(this).attr('color'));
		
		$("#carform").dialog( "close" );
    });
}
$(document).ready(function() { 
	$('#container').tabs({ fxSlide: true, fxFade: true, fxSpeed: 'slow' });
	$('#manufacturer').val("<?php echo $item['manufacturer']?>");
	
});
</script>

